package com.zyl.ag.ui.widget;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
import com.zyl.ag.MainActivity;
import com.zyl.ag.R;

public class WidgetProvider extends AppWidgetProvider {
	private static void setOnClickIntent(Context paramContext,
			RemoteViews paramRemoteViews, int paramInt, Intent paramIntent) {
		paramRemoteViews.setOnClickPendingIntent(paramInt,
				PendingIntent.getActivity(paramContext, 0, paramIntent, 0));
	}

	public static void updateTextAppWidget(Context context,
			AppWidgetManager paramAppWidgetManager, String paramString) {
		RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
				R.layout.text_widget);
		Intent localIntent = new Intent(context,
				MainActivity.class);
		remoteViews.setTextViewText(R.id.widget_text, paramString);
		setOnClickIntent(context, remoteViews, R.id.widget_layout, localIntent);
		paramAppWidgetManager.updateAppWidget(new ComponentName(context,
				WidgetProvider.class), remoteViews);
	}

	public void onUpdate(Context paramContext,
			AppWidgetManager paramAppWidgetManager, int[] paramArrayOfInt) {

		updateTextAppWidget(paramContext, paramAppWidgetManager, "");

	}

}
